<?php


namespace App\Repositories;


use App\EloquentORM\Article;

class ArticleRepositories extends BaseRepository
{
	public function __construct (Article $model)
	{
		$this->model = $model;
	}
	
	
	public function getSearch($like,$page=15)
	{
		$model = $this->model->query();
		if (is_integer ($like))
			$model->where ('id','=',$like)
				->orWhere('title','like','%'.$like.'%')
				->orWhere('content','like','%'.$like.'%')
				->orWhere('author','like','%'.$like.'%');
		else
			$model->where('title','like','%'.$like.'%')
				->orWhere('content','like','%'.$like.'%')
				->orWhere('author','like','%'.$like.'%');
		
		
		return $model->paginate ($page);
	}
}